<template>
    <view>
        <view style="padding: 40rpx;">
            <view>
                <view @click="() => onStartExam(childTiem)" v-for="(childTiem, childIndex) in practiceDtat"
                    :key="childTiem.id"
                    style="display: flex;justify-content: space-between;align-items: center;margin-bottom: 50rpx;padding-left: 40rpx;">
                    <view style="color: #333333; font-size: 16px;">
                        {{ onChangeDict(childTiem.type,
                            mapDictCodesData.allQuestionType) }} （{{ childTiem.itemNums }}）
                    </view>
                    <view style="display: flex;">
                        <text style="color: #666666; font-size: 14px;">查看</text>
                        <u-icon name="arrow-right" size="16"></u-icon>
                    </view>

                </view>

            </view>
        </view>
    </view>
</template>

<script>
import { listPractice, startPractice } from '../services/QuestionBankService';
import { mapDictCodes } from '../services/ServerService';
import { getArrObjectByProperty } from '../utils/PrjUtils';

export default {
    data() {
        return {
            marketId: '',
            practiceDtat: [],
            mapDictCodesData: {}
        }
    },
    onLoad(option) {
        this.marketId = option.marketId

    },
    computed: {},
    methods: {
        onMapDictCodes() {
            mapDictCodes('allQuestionType').then(res => {
                this.mapDictCodesData = res
            })
        },
        onListPractice() {
            listPractice({ marketId: this.marketId, practiceType: 3 }).then(res => {
                this.practiceDtat = res.children
            })
        },
        onChangeDict(val, dict) {
            console.log(val, 'vallllll');

            if (dict) {
                return getArrObjectByProperty(dict, 'value', val)?.label || ''
            }
        },
        // 开始练习 
        onStartExam(item) {
            console.log(item, 'item')
         
            startPractice({ practiceUuid: item.practiceUuid || '', marketId: this.marketId, practiceType: 3, structUuid:'', itemType: item.type || ''}).then(res => {
                uni.navigateTo({
                    url: '/pages/practiceTesting/exercisesPage?practiceUuid=' + res + '&video=true'
                })
            })
        }
    },
        onShow() {
            this.onMapDictCodes()
            this.onListPractice()
        },

    }
</script>

<style lang="scss">
page {
    background: #ffffff !important;
}
</style>